package com.redepronik.negosys.invfac.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * The persistent class for the token database table.
 * 
 */
@Entity
@Table(schema = "invfac", name = "token")
@NamedQuery(name = "Token.findAll", query = "SELECT t FROM Token t")
public class Token implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(allocationSize = 1, name = "TOKEN_TOKENID_GENERATOR", sequenceName = "INVFAC.TOKEN_TOKENID_SEQ")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TOKEN_TOKENID_GENERATOR")
	@Column(unique = true, nullable = false)
	private Integer tokenid;

	@Column(nullable = false, length = 30)
	private String nombre;

	// bi-directional many-to-one association to Parametro
	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "token")
	private List<Parametro> parametros;

	public Token() {
	}

	public Parametro addParametro(Parametro parametro) {
		getParametros().add(parametro);
		parametro.setToken(this);

		return parametro;
	}

	public String getNombre() {
		return this.nombre;
	}

	public List<Parametro> getParametros() {
		return this.parametros;
	}

	public Integer getTokenid() {
		return this.tokenid;
	}

	public Parametro removeParametro(Parametro parametro) {
		getParametros().remove(parametro);
		parametro.setToken(null);

		return parametro;
	}

	public void setNombre(String nombre) {
		this.nombre = nombre;
	}

	public void setParametros(List<Parametro> parametros) {
		this.parametros = parametros;
	}

	public void setTokenid(Integer tokenid) {
		this.tokenid = tokenid;
	}

}